local textChunks={} for i=0,24
table.insert(textChunks,{name="h_"..i,text="Pukul"..i})
end

require"import" import "android.os.Environment" import "android.speech.tts.TextToSpeech" import "android.speech.tts.UtteranceProgressListener" import "java.io.File" local tts=TextToSpeech(this,function(status) if status==TextToSpeech.ERROR service.asyncSpeak("TextToSpeech Tidak dapat digunakan") elseif status==TextToSpeech.SUCCESS service.asyncSpeak("Berhasil menggunakan TextToSpeech") synthesizetofile() end end) tts.setOnUtteranceProgressListener(UtteranceProgressListener{onStart=function service.playSoundGestureBegin() end,onStop=function service.playSoundGestureEnd() end,onDone=function service.playSoundScroll(1) end,onError=function service.beep() end}) function synthesizetofile() local folderpath=Environment.getExternalStorageDirectory().getAbsolutePath().."/Rekaman TTS/Berbicara jam dan baterai/jam_24" local file=File(folderpath) if not file.exists() file.mkdirs() end for i,v in ipairs(textChunks) local filename=v.name..".wav" local file=File(folderpath,filename) if not file.exists() local params={[TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID]=filename} tts.synthesizeToFile(v.text,params,folderpath.."/"..filename) end end end return true